import os

# 文件夹路径
folder = r'C:\\Users\\12286\Desktop\\资料'

# 原始后缀和新后缀
original_extension = '.png'
new_extension = '.jpg'

# 遍历文件夹中的所有文件
for filename in os.listdir(folder):
    if filename.endswith(original_extension):
        # 构建旧文件路径和新文件路径
        old_path = os.path.join(folder, filename)
        new_path = os.path.join(folder, filename.replace(original_extension, new_extension))
        
        # 重命名文件
        os.rename(old_path, new_path)

##
def operate_files(condition_func):
 current_dir = os.getcwd()
 for dirpath, dirnames, filenames in os.walk(current_dir):
   for filename in filenames:
     file_path = os.path.join(dirpath, filename)
     if condition_func(file_path):
       #操作
       print(file_path)
       pass
def is_txt_file(file_path):
  return file_path.endswith('.txt')

operate_files(is_txt_file)
##













